﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="Phoenix.Service.Model"%>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeadStyles" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadScripts" runat="server">
  <script type="text/javascript" src="/Scripts/m-former.js"></script>    
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="MainContent" runat="server">
  <% NewsCatalogModel objNewsCatalog =ViewData["NewsCatalogModel"] as NewsCatalogModel; %>

<div class="pd10">
    <form id="form1">
		<table class="tb-list mt10">
			<tr>
				<td class="aR" style="width:150px;">*类目名称：</td>
				<td class="aL">
				    <input type="text" id="txtCategoryName" name="txtCategoryName" value="<%=(objNewsCatalog!=null)?objNewsCatalog.CatalogName:"" %>" class="inputStyle"/>
				    <span id="spTxtCategoryName" style="display:none;"></span>
				</td>
			</tr>
			<tr>
				<td class="aR">*上级分类：</td>
				<td class="aL"><select id="sltParentCategoryID" name="sltParentCategoryID">
						<option value="0">顶级分类</option>
                        <% IList<NewsCatalogModel> NewsCatalogList =ViewData["NewsCatalogList"] as  List<Phoenix.Service.Model.NewsCatalogModel>; %>
						<%foreach (NewsCatalogModel c in NewsCatalogList)%>
						<%{%>
							<% if (objNewsCatalog != null && c.CatalogID == objNewsCatalog.ParentID) %>
							<%{%>
								<option value="<%=c.CatalogID %>" selected="selected"><%=c.CatalogName%></option>
							<%}%>
							<%else %>
							<%{ %>
								<option value="<%=c.CatalogID %>"><%=c.CatalogName%></option>
							<%} %>
						<%}%>
				   </select></td>
			</tr>
			<tr>
				<td class="aR">*排 序 值：</td>
				<td class="aL">
				    <input type="text" id="txtSort" name="txtSort" value="<%=(objNewsCatalog!=null)?objNewsCatalog.SortOrder.ToString():""%>" onkeyup="if(isNaN(this.value)){this.value=this.value.substring(0,this.value.length-1);}"  class="inputStyle"/>
				    <span id="spTxtSort" style="display:none;"></span>
				</td>
			</tr>
		</table>
	    <div class="mt10 aC">
	        <input type="hidden" name="hdCatalogID" value="<%=(objNewsCatalog!=null)?objNewsCatalog.CatalogID.ToString():"" %>" />     
            <input id="subbtn" type="button" value="保存" class="i-btn3"/>
            <input type="button" value="取消" onclick="cancel();" class="i-btn3"/>
	    </div>

    </form>
</div>

</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="BodyScripts" runat="server">
<script type="text/javascript">
    $("#form1").former({
        submit: 'subbtn',    //提交按钮id
        style: { right: 'icon-right', error: 'icon-error' },    //提示签标样式，融资管理后台不用修改
        ajax: true,         //开启ajax提交
        url: "/News/CatalogSave",    //提交url
        //验证规则
        validate: {
            txtCategoryName: {
                tipElem: 'spTxtCategoryName',
                rules: [
		                { rule: 'EMPTY', txt: '类目名称不能为空' },
		                { rule: 'LENGTH', min: 0, max: 50, txt: '长度不超过50' }
		            ]
            },
            txtSort: {
                tipElem: 'spTxtSort',
                rules: [
		                { rule: 'EMPTY', txt: '排序值不能为空' },
		                { rule: 'NUM', txt: '排序值必须是数字' }
		            ]
            }
        },
        //ajax提交成功执行
        success: function (data) {
            if (data.status === "warning" || data.status === "error") {
                alert(data.msg);
                return false;
            }
            // 操作成功
            alert(data.msg);
            // 执行回调方法
            successHandle();
        },
        //ajax提交失败执行
        error: function (jqXHR, textStatus, errorThrown) {
            alert('发生了未知错误');
        }
    });

    function cancel() {
        window.top.oDG.cancel();
    };

    /**
    * 弹窗处理
    */
    //窗口回调处理
    function successHandle() {
        window.top.winObj.refresh();
        window.top.oDG.cancel();
    };
</script>
</asp:Content>
